const bcrypt = require('bcryptjs');

async function generatePassword(plainPassword) {
    const salt = await bcrypt.genSalt(10);
    const hashedPassword = await bcrypt.hash(plainPassword, salt);
    console.log('原始密码:', plainPassword);
    console.log('加密密码:', hashedPassword);
    
    // 验证密码
    const isValid = await bcrypt.compare(plainPassword, hashedPassword);
    console.log('验证结果:', isValid);
}

// 测试密码生成
generatePassword('123456'); 